#Include "Protheus.ch"
// 420108
User Function RecSc6()

Local aArea   := GetArea()
Local cPedido := "420108"

dbSelectArea("SZS")
SZS->(dbSetOrder(1)) // ZS_FILIAL+ZS_ORDNOM
SZS->(MsSeek(xFilial("SZS") + cPedido))

While SZS->(!Eof()) .And. SZS->ZS_ORDNOM == cPedido

	SET DELETED OFF  // Desabilita filtro do campo D_E_L_E_T_
	
	SC6->(dbSetOrder(1))  // C6_FILIAL+C6_NUM+C6_ITEM+C6_PRODUTO
	SC6->(MsSeek(xFilial("SC6") + SZS->ZS_ORDNOM + SZS->ZS_ITEM))
	
	IF SC6->(Deleted())

		RecLock("SC6", .F.)
			SC6->(dbRecall())
		MsUnlock()
		
		RecLock("SZZ", .F.)
			SZS->ZS_STATPES := IF((SZS->ZS_PLIQTOL + SZS->ZS_PBRUTOL + SZS->ZS_FRMTOL + SZS->ZS_QTDCXS) > 0, "2", "1")
			SZS->ZS_STATUS := "1"
		MsUnlock()
	EndIF
	
	SET DELETED ON   // Habilita filtro do campo D_E_L_E_T_

	SZS->(dbSkip())

End

RestArea(aArea)

Return Nil

// ----------------------------------------------------------------------------------- //
/*
User Function RecSc6()

Local aArea := GetArea()
Local cLote := "30623DR0"

dbSelectArea("SZS")
SZS->(dbSetOrder(5)) // ZS_FILIAL+ZS_LOTE+ZS_ORDNOM+ZS_ITMNCOD
SZS->(MsSeek(xFilial("SZS") + cLote))

While SZS->(!Eof()) .And. SZS->ZS_LOTE == cLote

	SET DELETED OFF
	
	SC6->(dbSetOrder(1))  // C6_FILIAL+C6_NUM+C6_ITEM+C6_PRODUTO
	SC6->(MsSeek(xFilial("SC6") + SZS->ZS_ORDNOM + SZS->ZS_ITEM))
	
	IF SC6->(Deleted())

		RecLock("SC6", .F.)
			SC6->(dbRecall())
		MsUnlock()
		
		RecLock("SZZ", .F.)
			SZS->ZS_STATPES := IF((SZS->ZS_PLIQTOL + SZS->ZS_PBRUTOL + SZS->ZS_FRMTOL + SZS->ZS_QTDCXS) > 0, "2", "1")
			SZS->ZS_STATUS := "1"
		MsUnlock()
	EndIF
	
	SET DELETED ON

	SZS->(dbSkip())

End

RestArea(aArea)

Return Nil
*/